package cn.xiaobai.core;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.io.FileNotFoundException;
import java.io.RandomAccessFile;
import java.nio.charset.StandardCharsets;

/**
 * @Author yangdaji
 * @Date 2023/12/5
 * @PackageName cn.xiaobai
 * @ClassName ToolsApplication
 */
//@SpringBootApplication
public class ToolsApplication {


//    public static void main(String[] args) {
//        SpringApplication.run(ToolsApplication.class, args);
//
//    }

    public static void main(String[] args) {
        String path = "C:\\Users\\dell\\Desktop\\test\\java-demo\\5bf3048349e4c6f46ac4cef5357dca68.dat";
        try {
            RandomAccessFile randomAccessFile = new RandomAccessFile(path, "r");
            long fileSize = randomAccessFile.length();
            long currentPointer = 0;

            // 当前偏移量小于文件大小
            while (currentPointer < fileSize) {
//                byte[] buffer = new byte[1024];
//                randomAccessFile.readFully(buffer);
                String line = randomAccessFile.readLine();
//                String trim = new String(buffer, StandardCharsets.UTF_8).trim();
//                System.out.println("读取: " + trim);
                System.out.println("读取2: " + line);
                currentPointer = randomAccessFile.getFilePointer();
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }


}
